/*************************************************
 *  Search
 **************************************************/

// Search modal

.search-modal {
  transform: scale(0);
  -webkit-transform: scale(0);
  background-color: $sta-background;
  bottom: 0;
  left: 0;
  right: 0;
  top: 0;
  overflow: scroll;
  position: fixed;
  visibility: hidden;
  z-index: -99;
}

.dark .search-modal {
  background-color: $sta-dark-background;
}

// Hide body scrollbars whilst searching in modal
.searching {
  overflow: hidden;
}

.searching .search-modal {
  transform: scale(1);
  -webkit-transform: scale(1);
  visibility: visible;
  z-index: 1031; /* Highest index, higher than navbar. */
}

.searching #search-box #search-query {
  width: 100%;
}

.search-modal > .container {
  padding-top: 70px;  /* Navbar height. */
}
@media screen and (max-width: 1200px) {
  .search-modal > .container {
    padding-top: 50px;  /* Navbar height. */
  }
}

// Search modal header

.search-header {
  position: -webkit-sticky;
  position: sticky;
  top: 0;
  background-color: $sta-background;
  padding-top: 2rem;
  padding-bottom: 1rem;

  // Reduce top padding on mobile
  @include media-breakpoint-down(md) {
    padding-top: 0;
  }
}

.dark .search-header {
  background-color: $sta-dark-background;
}

.search-header h1 {
  margin: 0;
  line-height: 1;
}

.col-search-close {
  text-align: right;
}

// Large icon for closing search dialog.
.search-header .col-search-close i {
  font-size: 2rem;
  line-height: 1;
}

// Search box in modal

#search-box {
  position: relative; /* Required for search icon positioning. */
  margin-bottom: 0.5rem;
}

#search-box::before {
  font-family: 'Font Awesome 5 Free';
  font-weight: 900;
  content: "\f002";
  font-size: 1rem;
  opacity: 0.25;
  line-height: 1rem;
  position: absolute;
  left: 0.7rem;
  top: 0.6rem;
  overflow-x: hidden;
}

#search-box #search-query {
  border: 1px solid #dedede;
  border-radius: 1rem;
  padding: 1rem 1rem 1rem 2rem; /* Wider left padding for search icon to fit in. */
  width: 250px;
  line-height: 1rem;
  height: 1rem;
  font-size: 0.8rem;
}

.dark #search-query {
  background-color: $sta-dark-background;;
}

.form-control:focus {
  border-color: $sta-primary;
  box-shadow: 0 0 0 .2rem $sta-primary-light;
}

// Search result items

.search-hit em {
  font-style: normal;
  background-color: #FFE0B2;
  color: #E65100;
  border-bottom: 1px solid #E65100;
}

.search-hit-type {
  margin-bottom: 0 !important; /* Override .article-metadata margin. */
  text-transform: capitalize;
}

.search-hit-description {
  font-size: 0.7rem;
}

/* Load more results button - hide when there are no more results. */
#search-hits button[disabled] {
  display: none;
}

// Search button in Book sidebar

.sidebar-search {
  place-self: center start;
  display: flex;
  align-items: center;
}

.sidebar-search:hover {
  color: rgba(0,0,0,.8);
  box-shadow: inset 0 0 0 1px rgba(0,0,0,.1);
}

.dark .sidebar-search:hover {
  color: rgba(255,255,255,.8);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.9);
}

.sidebar-search-text {
  flex-grow: 1;
  text-align: left;
}

.sidebar-search-shortcut {
  font-family: Arial, "Helvetica Neue", Helvetica, sans-serif;
  box-shadow: 0 1px 1px rgba(12,13,14,0.15), inset 0 1px 0 0 #fff;
  flex-shrink: 0;
  padding: 1px 12px;
  margin: 0 0 0 10px;
  color: rgba(0,0,0,.6);
  font-size: 1.2rem;
  letter-spacing: 1px;
  background: rgb(228, 230, 232);
  border-radius: 5px;
  border: 1px solid rgb(159, 166, 173);
  line-height: 1.2;
}

// Common queries

#search-common-queries ul {
  // Empirically remove indentation due to `fa-ul`'s centered 2em spacing, wider than the search icon.
  margin-left: 0;
  padding-left: 1.6em;
}

#search-common-queries li {
  // Vertically align FA icons.
  line-height: 1;
}

#search-common-queries li a {
  // Color common search query links as body text.
  color: inherit;
}

.dark #search-common-queries li a {
  color: rgb(248, 248, 242);
}

// Algolia dark-themed search input

.dark .ais-search-box--input {
  background-color: $sta-dark-background;;
}
